import { Entity, Meaning } from "."

/** 学习进度 */
export enum ProgressType {
    /** 听力 */
    LISTEN,
    /** 发音 */
    SPEAK,
    /** 词意 */
    WORD_MEANING,
    /** 拼写 */
    SPELL,
}

export interface BaseProgress {
    type: ProgressType
    word: string
    proficiency: number // 熟练度，影响经验值的增长/减少速度
    exp: number // 经验值
    lastTestTime: number // 上次测试时间
    nextTestTime?: number // 下次测试时间，如果未到下次测试时间便不会安排测试
}

export interface WordProgresses {
    listen: Entity<ListenProgress>
    speak: Entity<SpeakProgress>
    meaning: Entity<MeaningProgress[]>
    spell: Entity<SpellProgress>
}

/** 学习进度 */
export type LearningProgress =
    | ListenProgress
    | SpeakProgress
    | MeaningProgress
    | SpellProgress

export interface ListenProgress extends BaseProgress {
    type: ProgressType.LISTEN
}

export interface SpeakProgress extends BaseProgress {
    type: ProgressType.SPEAK
}

export interface MeaningProgress extends BaseProgress {
    type: ProgressType.WORD_MEANING
    meaning: Meaning
}

export interface SpellProgress extends BaseProgress {
    type: ProgressType.SPELL
}
